﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Person_Mobile
{
    public partial class WindowsPhoneControl1 : UserControl
    {
        public MainPage main;
        public string command = "";
        public int oldID = 0;
        public WindowsPhoneControl1()
        {
            InitializeComponent();
        }



        private void Btn_OK_Click(object sender, RoutedEventArgs e)
        {
            PersonService.Person p = new PersonService.Person();
            p.Id = Convert.ToInt32(Textbox_id.Text);
            p.FName = TextBox_name.Text;
            p.LName = TextBox_add1.Text;
            p.Age = Convert.ToInt32(TextBox_add2.Text);

          
                if (command == "Create")
                {
                    main.ds.Update(p);
                }
                else if (command == "Edit")
                {
                    main.ds.Update(p);
                }

            main.NewPanel.Margin = new Thickness(1000, 0, 0, 0);
            main.Listbox_persons.Margin = new Thickness(0, 0, 0, 0);
        }

        private void Btn_Cancel_Click(object sender, RoutedEventArgs e)
        {
            main.NewPanel.Margin = new Thickness(1000, 0, 0, 0);
            main.Listbox_persons.Margin = new Thickness(0, 0, 0, 0);
        }
    }
}
